const express = require("express")

const app = express()

// app.use((req, res, next) => {
//   //body-parser 插件
//   if (req.headers["content-type"] == "application/json") {
//     req.on("data", (data) => {
//       const info = JSON.parse(data.toString())
//       req.body = info
//     })
//     req.on("end", () => {
//       next()
//     })
//   } else {
//     next()
//   }
// })

app.use(express.json())
app.use(express.urlencoded({ extended: true }))


app.post('/login', (req, res, next) => {
  console.log(req.body);
  res.end("end")
})

app.post('/products', (req, res, next) => {
  console.log(req.body);
  res.end("end")
})


app.listen(8000, () => {
  console.log("普通的中间件");
})